import request from '@/utils/request'

// 分类：获取文章分类
export const artGetChannelsService = () => {
  return request.get('/my/cate/list')
}

// 分类：新增文章分类
export const artAddChannelsService = ({ cate_name, cate_alias }) => {
  return request.post('/my/cate/add', { cate_name, cate_alias })
}

// 分类：修改文章分类
export const artEditChannelsService = ({ id, cate_name, cate_alias }) => {
  return request.put('/my/cate/info', { id, cate_name, cate_alias })
}

// 分类：删除文章分类
export const artDelChannelsService = (id) => {
  return request({
    url: '/my/cate/del',
    method: 'DELETE',
    params: {
      id
    }
  })
}

// 文章:获取文章列表
export const artGetListService = ({ pagenum, pagesize, cate_id, state }) => {
  return request({
    url: '/my/article/list',
    method: 'get',
    params: { pagenum, pagesize, cate_id, state }
  })
}

// 文章：发布文章
export const artPublishService = (data) => {
  // 注意:这里的data不是普通对象,而是FormData对象,根据接口文档来
  return request.post('/my/article/add', data)
}

// 文章:获取文章详情(为了回显表单)
export const artGetDetailService = (id) => {
  return request.get('/my/article/info', {
    params: { id }
  })
}

// 文章：修改文章
export const artEditService = (data) => {
  // 注意:这里的data不是普通对象,而是FormData对象,根据接口文档来
  return request.put('/my/article/info', data)
}

// 文章：删除文章
export const artDelService = (id) => {
  return request.delete('/my/article/info', {
    params: { id }
  })
}
